package com.hluck.navigationviewmodel

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View

class MyCustomView(context: Context,attrs:AttributeSet?):View(context,attrs) {

    private var lastX = 0
    private var lastY = 0


    override fun onTouchEvent(event: MotionEvent?): Boolean {

        when(event!!.action){
            MotionEvent.ACTION_DOWN -> {
                lastX = event.x.toInt()
                lastY = event.y.toInt()
            }
            MotionEvent.ACTION_MOVE -> {
                val offsetX = event.x - lastX
                val offsetY = event.y - lastY
//                layout((left+offsetX).toInt(), (top+offsetY).toInt(), (right+offsetX).toInt(),
//                    (bottom+offsetY).toInt()
//                )
                offsetLeftAndRight(offsetX.toInt())
                offsetTopAndBottom(offsetY.toInt())
            }
        }

        return true
    }

}